home *** CD-ROM | disk | FTP | other *** search
- Path: ix.netcom.com!netnews
- From: Manuel Hernandez <ManuelHe@ix.netcom.com>
- Newsgroups: comp.lang.c++
- Subject: Re: cin.get(string) problem
- Date: 11 Feb 1996 07:55:49 GMT
- Organization: Netcom
- Message-ID: <4fk7e5$j9h@cloner3.netcom.com>
- NNTP-Posting-Host: irv-ca9-20.ix.netcom.com
- X-NETCOM-Date: Sat Feb 10 11:55:49 PM PST 1996
-
- greinerk@ix.netcom.com (Kurt W. Greiner) writes:
- > Hi all,
- > i was trying some really simple io for a program that just gets
- > values, here is a sample of code
- >
- > #include <iostream.h>
- >
- > void main(void)
- > {
- > char string[80];
- > cin.get(string,sizeof(string));
- > cin.get(string,sizeof(string));
- > }
- >
- > ok, say i want to read in a name on the first cin, i type in "john smith" and
- > the prompt, john gets thrown in to the first and smith the second, i do not
- > even get prompted for the second cin. it does not happen if i type in a string
- > with out spaces. i am using borland c++ 2.0, am i doing something wrong or is
- > there an other way of doing this other than gets(string)?
- >
- > kurt
- I wish I could help you because I am experiencing the same sort of
- problems. First I to input into a string with a cin.getline. second I
- input an integer with " cin>> variable ". Next I try and input a second
- string. When I run the code I don't get prompted for the second string. I have
- I have been told it has to do with the computer recoginzing the
- null terminator, so that is what I will tell you.
-
- What do you get when you step through your code? I could not interpret the
- <iostream.h> very well. I went to buy a book that specialized in iostream programming
- but it was forty bucks. I can't afford to spend $40 everytime I hit a snag unless I can't
- find the answer elsewhere. I will search the net to see if I can find references to
- cin and recognizing the end of line character. I'll keep you posted
-
-